import { useSelector, useDispatch } from 'react-redux'
import { updateCountAction } from '../store/actions/counter.js'

export default function Counter() {
  const num = useSelector(state => state.counter)
  const dispatch = useDispatch()

  return (
    <div>
      <h1>Count值是：{num}</h1>
      <button onClick={() => dispatch(updateCountAction(1))}>+1</button>
      <button onClick={() => dispatch(updateCountAction(-1))}>-1</button>
    </div>
  )
}
